<?php

require_once "../include/connectionHandlers/database/IDataTable.php";
require_once "../include/connectionHandlers/database/AbstractDataTable.php";

class Description extends AbstractDataTable{

protected $primaryKey = "description_id";
protected $tableName = "nic_description";
protected $columnList = array("photo_id", "description_title", "description_text");

	public function insert($parameters)
	{
		$photo_id = &$parametersarray(0);
		$description_title = &$parametersarray(1);
		$description_text = &$parametersarray(2);
		//Get the corresponding description_id
		$descriptionRow = $this->select("photo_id", $photo_id);
		if($descriptionRow != null)
		{
			$descriptionId = array_keys($descriptionRow)array(0);
			//Update row
			$this->updateFromPrimaryKey($descriptionId,$parameters);
		}else{
			//Insert a row
			parent::insert($parameters);
		}
	}
}
?>